package ar.uba.fi.RSACryptoFiuba.view.commons;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class NavigableKeyActionListener implements KeyListener{

	public void keyTyped(KeyEvent e) {
		proceed(e);				
	}

	private void proceed(KeyEvent e) {
		if (isNotAllowedKey(e)) {
			e.consume();
		}
	}

	private boolean isNotAllowedKey(KeyEvent e) {
		return e.getKeyCode() != KeyEvent.VK_LEFT && e.getKeyCode() != KeyEvent.VK_RIGHT && e.getKeyCode() != KeyEvent.VK_END && e.getKeyCode() != KeyEvent.VK_HOME;
	}
	
	public void keyReleased(KeyEvent e) {
		proceed(e);				
	}
	
	public void keyPressed(KeyEvent e) {
		proceed(e);
	}
}
